<template>
	<view class="content " :style="{paddingTop: yemiangao+'px'}">

		<view class="d-kuan-juzhong ">
			<!--头部-->
			<view class="d-kuan pc-dingbu">
				<DToubu 
				ref="dToubu" 
				@login-success="handleLoginSuccess"
				@clear-audio="clearAllAudio" 
				@logout-success="handleLogout"
				:dengluxianshi="denglu_xianshi"
				@update-dengluxianshi="handleUpdateDengluxianshi"
				@www-data="wwwdataget"
				></DToubu>
			</view>

			<!--头部-->
			<!--下面内容-->
			<view class="d-kuan d-clear">
				<uv-row customStyle="margin-bottom: 10px" :gutter="10">
					<!-- #ifdef H5 -->
					<uv-col span="2" class="pc-yincang">
						<!--左边导航-->
							<view class="d-daohang d-you-10 pc-yincang  d-shang-20" id="zuo-daohang" :style="{height: leftNavHeight}">
								<view class="d-daohang-5 " >
									<Ddaohang @denglu-fabu="denglu_fabu"></Ddaohang>
								</view>
							</view>
					</uv-col>
					<!-- #endif -->
					<uv-col :span="kuan_shu" class="daohangkuan" style="position: relative;">
						<view class="pc-neikuang-20" >
							
							<view class="daohang-guding daohanggao" 
								:style="{
								    'position': 'fixed', 
								    'top': daohang_top_2+'px', 
								    'z-index': 99, 
								    'background': '#f3f3f3',
								    'padding': '10rpx',
								    'width': daohangkuanzhi   // 替换未定义的rightColWidth
								}">
								<!--小程序高度-->
								<!--#ifdef MP-WEIXIN-->
								    <view class="d-kuan d-gao-60">
									</view>
								<!--#endif-->
								<uv-tabs :list="quan_daohang_list" :current="1" @click="yiji2" lineColor="#07bfa6" :activeStyle="{ color: '#0a9a87' }"></uv-tabs>

								<uv-tabs v-if="quan_daohang_list.length > 0 " :key="'erji-' + activeIndex.id"  :current="xuanzezhi" :list="erjidata" @click="erji2" lineColor="#07bfa6" :activeStyle="{ color: '#0a9a87'}"></uv-tabs>
							</view>
							<view class="d-kuan" :style="{ 'margin-top': daohanggaoHeight }"></view>
							<view v-if="wwwdata && wwwdata.setting && wwwdata.setting.quan_moshi != 1" class="d-kuan d-gao-60">
								<uv-button @click="shenqing" class="d-shang-10 d-jiacu d-wenzi-16" type="default" shape="circle"  :plain="true" text="申请圈子"></uv-button>
							</view>
							<uv-row :customStyle="{'flex-wrap': 'wrap' }"  :gutter="20" wrap>
									<uv-col v-for="(list,index) in quan_list" :span="kuan_quan" :key="index">
										<view class="beijing-140 d-kuan  d-xia-20" >
											<!--#ifdef MP-WEIXIN-->
											    <view class="d-kuan d-gao-5">
												</view>
											<!--#endif-->
											<view class="d-buhuanhang d-shang-10">
												<!--图片-->
												<view class="d-zuo d-tu-kuan-140 d-piaofu-0" style="display: flex; justify-content: center; align-items: center;">
													<!--view v-if="list.moshi==0" class="d-piaofu-1">免费</view>
													<view v-else class="d-piaofu-1">付费</view-->
													<uv-image :src="list.thumb" width="100rpx" height="100rpx" radius="50"></uv-image>
												</view>
												<view class="d-kuan d-neikuang-10 d-piaofu-jiage-0">
													<view v-if="list.jiaru == 0"  >
														<text v-if="list.kaifangfabu == 1 && list.jiage == 0" class="d-piaofu-jiage-3" @click="jiaquan(list.id)">+免费加入</text>
														<text v-if="list.kaifangfabu == 1 && list.jiage > 0" class="d-piaofu-jiage-5" @click="quan(list.id)">+付费加入</text>
														<text v-if="list.kaifangfabu == 0" class="d-piaofu-jiage-6" @click="quan(list.id)">+阅读</text>
													</view>
													<view v-if="list.jiaru == 1"  >
														<text v-if="list.kaifangfabu == 1 && list.jiage == 0 || list.uid == uid || list.kaifangfabu == 1 && list.jiage > 0" @click="fabu(list.id,list.title)" class="d-piaofu-jiage-3">发布</text>
													    <text v-else-if="list.kaifangfabu == 0" class="d-piaofu-jiage-6" @click="quan(list.id)">+阅读</text>
													</view>
													<view class="d-chaochu-1 d-jiacu" @click="quan(list.id)">{{list.title}}</view>
													<view class=" d-ziti-12 d-wenzi-yanse-hui d-shangxia-5 d-buhuanhang">
														<view v-if="list.jiage > 0" class="d-piaofu-jiage-2 d-you-5">付费</view>
														<view class="d-chaochu-1 ">{{list.description}}</view>
													</view>
													<!--view class="d-chaochu-1 d-ziti-12 d-wenzi-yanse-hui d-shangxia-10">
														<uv-icon name="arrow-right" color="#a7a7a7" labelColor="#a7a7a7" size="10" :label="list.catname"></uv-icon>
													</view-->
												</view>
											</view>
											<!--统计-->
											<view class="d-kuan d-clear d-shang-10"  @click="quan(list.id)">
													<uv-grid :col="4"  :border="true">
											    	    <uv-grid-item >
															<uv-icon :customStyle="{paddingTop:20+'rpx'}" color="#a2a2a2" labelColor="#7e7e7e" :label="list.jiaru_total" :size="22"></uv-icon>
											    			<text class="grid-text  d-shang-10 d-wenzi-12" style="color: #a2a2a2;">成员</text>
											    		</uv-grid-item>
														<uv-grid-item >
															<uv-icon :customStyle="{paddingTop:20+'rpx'}" color="#a2a2a2" labelColor="#7e7e7e" :label="list.quantie_total" :size="22"></uv-icon>
															<text class="grid-text  d-shang-10 d-wenzi-12" style="color: #a2a2a2;">主题</text>
														</uv-grid-item>
														<uv-grid-item >
															<uv-icon :customStyle="{paddingTop:20+'rpx'}" color="#a2a2a2" labelColor="#7e7e7e" :label="list.tianshu" :size="22"></uv-icon>
															<text class="grid-text  d-shang-10 d-wenzi-12" style="color: #a2a2a2;">运营天数</text>
														</uv-grid-item>
														<uv-grid-item >
															<uv-icon :customStyle="{paddingTop:20+'rpx'}" color="#a2a2a2" labelColor="#7e7e7e" :label="list.wenda_shu" :size="22"></uv-icon>
															<text class="grid-text  d-shang-10 d-wenzi-12" style="color: #a2a2a2;">问答</text>
														</uv-grid-item>
											    	</uv-grid>
													<view class="d-clear d-kuan" style="height:20px;"></view>
												
												

											</view>
											<view class="d-clear"></view>
											


										</view>
										<view class="d-clear"></view>
										

									</uv-col>
									<!-- 加载状态提示 -->
  									<view class="d-kuan d-juzhong d-shangxia-20" v-if="isLoading">
  									  <!--uv-loading></uv-loading-->
  									</view>
  									<view class="d-kuan d-juzhong d-shangxia-20 d-wenzi-hui" v-if="noMoreData">
  									  <uv-divider text="没有更多数据了"></uv-divider>
  									</view>

								</uv-row>

						</view>

					</uv-col>
					<!-- #ifdef H5 -->
					<uv-col span="3" class="pc-yincang">
						<view v-if="wwwdata && wwwdata.setting && wwwdata.setting.quan_moshi != 1" class="d-daohang d-you-10 pc-yincang d-shang-20" id="zuo-daohang" :style="{height: leftNavHeight}">
							<view class="d-you-kuang">
								<view class="d-kuan  " id="yuedu_gao" :style="{height: leftNavHeight,width: rightColWidth,marginTop: '10px'}">
									<view class=" gundong-2"  style="height: 100%; display: flex; flex-direction: column;overflow-y: auto;">
										<view class="d-yuanjiao-10  d-beijing-e3 d-bianhua-10 ">
											<view class="d-kuan ">
												
												<uv-button @click="shenqing" class="d-shang-10 d-jiacu d-wenzi-16" type="default" shape="circle"  :plain="true" text="申请圈子"></uv-button>
												<view class="d-shang-10 d-jiacu d-wenzi-16 d-neirong-juzhong d-shangxia-10">

													你有 {{ shenquan_tongji }} 个圈子待审核
												</view>
												
												<view class="d-clear"></view>
												<uv-cell-group>
													<uv-cell v-for="(list,index) in shenquan_list" :key="index"  icon="more-circle" :title="list.content && list.content.title+' 圈子'">

														<!-- 自定义左侧标题下面的内容 -->
														<template v-slot:label>
															<text style="font-size: 28rpx;color: #999;">
																{{ list.content && list.content.inputtime }} 
															</text>
														</template>
														<!-- 自定义右侧值 -->
														<template v-slot:value>
															<text>待审核</text>
														</template>
													</uv-cell>
													
												</uv-cell-group>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>

					</uv-col>
					<!-- #endif -->
				</uv-row>

				

			</view>
			<!--下面内容-->

		</view>
		<!--底部登录-->
		<Dweibudenglu
			ref="weibudenglu"
			:denglu_xianshi_weibu="denglu_xianshi_weibu"
			@denglu_close_get="denglu_close_get"
		>
		</Dweibudenglu>
	</view>
</template>

<script>
    import Api from '@/utils/api.js';
	import QuanApi from '@/utils/quan_api.js';
	//var wxRequest_2 = require("../../utils/wxRequest.js");
	import { getRequest,postRequest } from '@/utils/wxRequest.js';
    //引入组件 d-toubu
    import DToubu from '@/components/d-toubu/d-toubu.vue'
	import Ddaohang from '@/components/d-daohang/d-daohang.vue'
	import Dweibudenglu from '@/components/d-weibu-denglu/d-weibu-denglu.vue'
	export default {
		data() {
			return {
				id:'',
				title: 'Hello',
				leftNavHeight: '500rpx', // 默认高度
				daohangkuanzhi: '50%', // 默认值
				rightColWidth: '300px', // 默认宽度
				rightColLeft: '0px', // 添加这个属性
				daohang_top:'60',

				daohang: [
					{
						id:'1',
						name: '首页', 
						icon: 'home',

					},
					{
						id:'2',
						name: '心理学',
						icon: 'home',
						erji: [	
							{id: '2-1', name: '情绪管理'},
					    	{id: '2-2', name: '心理疗愈'},
					    	{id: '2-3', name: '行为心理学'}
						]
					},
					
				],
				denglu_xianshi:0, // 登录显示
				erjidata:[],
				erjiindex:'',//当前激活的二级菜单索引
				activeIndex: -1, // 当前激活的一级菜单索引
				quan_daohang_list:[], // 知识导航列表
				quan_list:[], // 圈子列表
				xuanzezhi:0, // 知识列表
				daohanggaoHeight: '0px', // 导航栏高度

				currentPage: 1, //下拉加载
    			pageSize: 12, //下拉加载
    			isLoading: false, //下拉加载
    			noMoreData: false, //下拉加载
				kuan_shu: 8, //格大小
				kuan_quan:6,//格大小
				yemiangao:70, //顶部导航栏
				shenquan_list:[], // 申请的圈子列表
				shenquan_tongji:0, // 申请的圈子统计
				daohang_top_2:0,
				denglu_xianshi_weibu:0,//显示登录
				wwwdata:{}, // 站点设置



			}
		},
		components: {
  		    DToubu,
			Ddaohang,
			Dweibudenglu
  		},
		computed: {
		  	yidenglu() {
		  	  return (this.$store.state.memberuid && this.$store.state.keycode) ? 1 : 0;
		  	},
		  	touxiang() {
		  	  return this.$store.state.member? this.$store.state.member.avatar : '';
		  	},
		  	name1() {
		  	  return this.$store.state.member? this.$store.state.member.name : '';
		  	},
			uid: {
		  	  get() {
		  	    return this.$store.state.memberuid;
		  	  },
		  	  set(value) {
		  	    // 计算属性'uid'是只读的，不应该被修改
		  	    //console.warn('计算属性"uid"是只读的，不能被修改');
		  	  }
		  	},
		  	keycode: {
		  	  get() {
		  	    return this.$store.state.keycode;
		  	  },
		  	  set(value) {
		  	    // 计算属性'keycode'是只读的，不应该被修改
		  	    //console.warn('计算属性"keycode"是只读的，不能被修改');
		  	  }
		  	},
			pc() {
			  return this.$store.state.kuan.pc;
			},
		},

		onReachBottom() {
  			this.onReachBottom(); //下拉加载分页
  		},
		mounted() {
			//var m = this.$store.state;
			//console.log('mmmm',m);
			
    	    this.setLeftNavHeight();
			this.getRightColWidth(); // 添加这行
			
    	    // 添加窗口大小变化监听
			// #ifdef H5
    	    window.addEventListener('resize', this.setLeftNavHeight);
			window.addEventListener('resize', this.getRightColWidth); // 添加窗口大小变化监听
			// #endif
			this.quangao();
			this.$nextTick(() => {
				
				// 计算高度
				//this.calcDaohanggaoHeight();
    		});

    	},
    	beforeDestroy() {
    	    // 移除监听
    	    // #ifdef H5
    	    window.removeEventListener('resize', this.setLeftNavHeight);
			window.removeEventListener('resize', this.getRightColWidth); // 添加这行
    	    // #endif
			//this.clearAllAudio();
    	},
		onShow() {
			//var m = this.$store.state;
			//console.log('12300000:', this.$store.state.memberuid);
			// 每次显示页面时，更新当前页面状态到本地存储
			uni.setStorageSync('currentPage', 'quan/index');
			this.quan_daohang_api();
			var e = this;
			this.quan_list_api(e,false);
			this.getShenqing_uid_list_api();
			
		},
		onLoad(e) {
			// 获取URL参数
			this.id = e.id || '';
			//console.log('圈子id',this.id);
			
		},
		methods: {
			//加入圈子
			jiaru_api(){
				const uid = this.$store.state.memberuid;
				const keycode = this.$store.state.keycode;
				if (!uid || !keycode) {
				    uni.showToast({
				        title: '未登录',
				        icon: 'none'
				    });
					this.denglu_xianshi = 1;
				    return;
				}
			},
			//发布
			fabu(id,title){
				
				getApp().globalData.currentId = id;
				getApp().globalData.title = title;
			
				uni.navigateTo({
					url: '/pages/fabu/index?id='+id,
					success: () => {
					  console.log('跳转成功');
					  
					},
					fail: (err) => {
					  console.error('跳转失败:', err);
					  uni.showToast({
							title: '跳转失败，请重试',
							icon: 'none'
					  });
					}
				});
			},
			// 发布登录
			denglu_fabu(){
				if(this.yidenglu == 0){
					this.denglu_xianshi = 1;
				} else {
					this.denglu_xianshi = 0;	
				}
				
				//console.log('发布登录',this.denglu_xianshi);
				
			},
			// 更新判断是否登录
			handleUpdateDengluxianshi(value) {
			  	this.denglu_xianshi = value;
			  	//console.log('关闭登录',this.denglu_xianshi);
			},
			// 退出登录
			handleLogout() {
 			  // 用户退出时关闭阅读界面
 			  this.yuedu = false;
 			  // 停止并销毁音频
 			  if(this.$refs.audioPlayer) {
 			    const audioCtx = this.$refs.audioPlayer.getAudioContext();
 			    audioCtx.stop();
 			    audioCtx.destroy();
 			  }
			  var e = this;
			  this.quan_list_api(e,false);
			   //this.getDianzan_panduan_api(); // 退出登录后重新获取点赞状态
			   //this.getShoucang_panduan_api(); // 退出登录后重新获取收藏判断
 			},
			// 登录
			handleLogin() {
				//this.getDianzan_panduan_api(); // 登录后重新获取点赞状态
				//this.getShoucang_panduan_api(); //登录后重新获取收藏判断
				var e = this;
				this.quan_list_api(e,false);
			},
			getRightColWidth() {
				// 获取系统信息
				const query_2 = uni.createSelectorQuery().in(this);
				const systemInfo = uni.getSystemInfoSync();
        	    // 计算可用高度（可根据实际需求调整计算方式）
        	    const windowWidth = systemInfo.windowWidth;
				
				var d = this;            
               this.$nextTick(() => {
					if(this.pc){
						query_2.select('.daohangkuan').boundingClientRect(data => {
    		    		    if (data) {
    		    		        this.daohangkuanzhi = `${data.width-150}px`;
    		    		    }
    		    		}).exec();

						d.gao = 20;
						d.kuan_shu = 7;
						d.kuan_quan = 6;
						d.swiperHeight = '250';
						d.daohang_top = '60';
						d.yemiangao = '60';
						d.daohang_top_2 = '60';
					} else {
						d.gao = 10;
						d.kuan_shu = 12;
						d.kuan_quan = 12;
						d.swiperHeight = '120';
						d.daohang_top = '70';
						d.yemiangao = '50';
						d.daohang_top_2 = '0';
						this.daohangkuanzhi = '100%'; // 或其他适合的默认值


					}

                 const query = uni.createSelectorQuery().in(this);
                 query.select('#youbiankuan').boundingClientRect(rect => {
                   if (rect) {
                     /*this.rightColWidth = `${rect.width+20}px`;
                     console.log('右侧列宽度:', this.rightColWidth);*/
					 	this.rightColWidth = `${rect.width-80}px`;
                    	this.rightColLeft = `${rect.left}px`; // 计算左侧位置
                    	console.log('右侧列位置:', this.rightColWidth);
                   }
                 }).exec();
               });
            },

			calcDaohanggaoHeight() {
				// 获取系统信息
				/*const query_2 = uni.createSelectorQuery().in(this);
				const systemInfo = uni.getSystemInfoSync();
				// 计算可用高度（可根据实际需求调整计算方式）
				const windowWidth = systemInfo.windowWidth;*/
				this.$nextTick(() => {

    		    	const query = uni.createSelectorQuery().in(this);
    		    	query.select('.daohanggao').boundingClientRect(data => {
    		    	    if (data) {
							if(this.pc){
								this.daohanggaoHeight = `${data.height+10}px`;
								console.log('导航栏高度768:', this.daohanggaoHeight);
							} else {
								this.daohanggaoHeight = `0px`;
								this.yemiangao = `${data.height}`;
								console.log('导航栏高度0:', this.daohanggaoHeight);
							}
    		    	        
    		    	    }
    		    	}).exec();
				});
    		},
			quangao(){
				// 获取系统信息
				/*const query_2 = uni.createSelectorQuery().in(this);
				const systemInfo = uni.getSystemInfoSync();
				// 计算可用高度（可根据实际需求调整计算方式）
				const windowWidth = systemInfo.windowWidth;*/
				// #ifdef H5
				if(this.pc){
					
					this.daohanggaoHeight = `55px`;
					
				} else {
					
					this.daohanggaoHeight = `0px`;
					
				}
				// #endif
				// #ifdef MP-WEIXIN
				    this.daohanggaoHeight = `70px`;
				// #endif
			},

			//首页
			shouye(){
				uni.navigateTo({
					url: '/pages/index/index',
					fail: (err) => {
						console.error('跳转失败:', err)
					}
				})
			},
			// ...其他方法保持不变...
			yiji(index) {
    		  // 切换激活的一级菜单
    		  this.activeIndex = index;
    		  // 根据激活的一级菜单显示对应的二级菜单
			  if(index == 0){
				  this.erjidata = [];
			  }else{
				  this.erjidata = this.quan_daohang_list[index].son;
			  }
			  const data = {
				  categories:index
			  }
			  this.quan_list_api(data,true);
    		  //
			  console.log(this.erjidata);
    		},
			erji(index) {
    		  // 切换激活的二级菜单
    		  this.erjiindex = index;

			  const data = {
				  categories:index
			  }
			  this.quan_list_api(data,true);
			  //console.log(index);

    		},
			yiji2(index) {
					//
					if (index.id === '-1') {
						// 返回上一页；若无上一页则跳到首页
						try {
							const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : null;
							if (pages && pages.length > 1) {
								uni.navigateBack({ delta: 1 });
							} else {
								// 优先跳到首页 tab
								uni.switchTab({
									url: '/pages/index/index',
									fail: (err) => {
										console.warn('switchTab 到首页失败，尝试重启到首页:', err);
										uni.reLaunch({ url: '/pages/index/index' });
									}
								});
							}
						} catch (e) {
							// 兜底处理：直接重启到首页
							uni.reLaunch({ url: '/pages/index/index' });
						}
						return;
					}
					this.xuanzezhi = 0;
					
					//console.log('000',index.id);
    		  // 切换激活的一级菜单
			  setTimeout(() => {

    			  	this.activeIndex = index;
    			  	// 根据激活的一级菜单显示对应的二级菜单
				  	if(index.id == 0){
						  this.erjidata = [];
				  	}else{
						  this.erjidata = this.quan_daohang_list[index.index].son;
						  
				  	}
				  	const data = {
						  categories:index.id,
						  page: 1 // 重置页码
				  	}
					this.currentPage = 1; // 重置页码
					this.noMoreData = false; // 重置无更多数据标志
				  	this.quan_list_api(data,false);
					  this.calcDaohanggaoHeight();
				}, 300);
    		  
			  
    		},
			erji2(index) {
				this.xuanzezhi = index.index;
    		  // 切换激活的二级菜单
    		  this.erjiindex = index.id;
			  this.activeIndex = index;

			  const data = {
				  categories:index.id,
				  page: 1 // 重置页码
			  }
			    this.currentPage = 1; // 重置页码
				this.noMoreData = false; // 重置无更多数据标志

			  this.quan_list_api(data,false);
			  //console.log('二级分类：',index);

    		},

			toggleErji(index) {
				
    		  if (this.activeIndex === index) {
    		    // 点击已激活的菜单，收起二级菜单
    		    this.activeIndex = -1;
    		    this.currentErji = [];
    		  } else {
    		    // 点击新的菜单，显示对应的二级菜单
    		    this.activeIndex = index;
    		    this.currentErji = this.quan_daohang_list[index].erji;
    		  }
    		},
			setLeftNavHeight() {
        	    // 获取系统信息
        	    const systemInfo = uni.getSystemInfoSync();
        	    // 计算可用高度（可根据实际需求调整计算方式）
        	    const windowHeight = systemInfo.windowHeight;
        	    const headerHeight = 70; // 头部高度估计值
        	    const calculatedHeight = windowHeight - headerHeight;
				
        	    // 设置左边导航高度
        	    this.leftNavHeight = `${calculatedHeight}px`;
        	},
			zhishi(id){
				console.log(id);
				try {
  				  uni.navigateTo({
  				    url: '/pages/zhishi/index?id='+id,
  				    fail: (err) => {
  				      console.error('跳转失败:', err)
  				    }
  				  })
  				} catch (e) {
  				  console.error('跳转异常:', e)
  				}
			},
			
			handleLoginSuccess() {
				var e = this;
				this.quan_list_api(e,false);
  			  this.$forceUpdate();
  			},
			// 导航接口
			quan_daohang_api(){
				var get_data = getRequest(Api.getQuan_daohang());
				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						// 转换时间戳为日期格式
						//var list = res.data ? res.data.data : {};
						var list = res.data && res.data.data ? res.data.data.lisi2 : [];
						// 在 list 前面添加插入一个新的数据“首页”
						list.unshift({
            			    id: '-1',
							pid: '-1',
            			    name: '返回',
            			    icon: 'home',
            			    son: [] // 首页没有二级菜单
            			});
        				this.quan_daohang_list = list;
						//console.log(list);
					} else {
						/*uni.showToast({
							icon: 'none',
							title: '获取失败，请稍后重试'
						});*/
					}
				})
			},
			//列表接口
			quan_list_api(data, isLoadMore = false){
				data.uid = this.$store.state.memberuid;
				data.jiauid = this.$store.state.memberuid;
				data.keycode = this.$store.state.keycode;
				if (!data) data = {};
				if (!data) data = {};
		  		if (!data.page) data.page = 1;
		  		if (!data.categories) data.categories = 0;
		  		if (!data.search) data.search = '';
				// getRequest 第二个参数应为对象；且 QuanApi.getQuan_list 已在 URL 中包含 uid/keycode 等参数，无需再传 datas
				var get_data = getRequest(QuanApi.getQuan_list(data));
				var res;	
				get_data.then(duixin_data => {
					res = duixin_data;	
					if(res.data.code) {
						// 转换时间戳为日期格式
						var list = res.data? res.data.data.list : {};
						// 合并数据
						if (isLoadMore) {
        				  // 加载更多时追加数据
        				  this.quan_list = [...this.quan_list, ...list];
        				} else {
        				  // 非加载更多时替换数据
        				  this.quan_list = list;
        				}	
						// 判断是否还有更多数据
						this.noMoreData = list.length < this.pageSize;
					} else {
						uni.showToast({
							icon: 'none',
							title: '获取失败，请稍后重试'
						});
					}
					this.isLoading = false;
				}).catch(() => {
    			  this.isLoading = false;
    			  if (isLoadMore) {
    			    this.currentPage--; // 加载失败时回退页码
    			  }
    			});
			},
			// 下拉加载更多
  			onReachBottom() {
  			  if (this.isLoading || this.noMoreData) return;
  			  this.isLoading = true;
  			  this.currentPage++;
			  // 获取当前激活的分类ID
    			const currentCategoryId = this.activeIndex.id >= 0 ? this.activeIndex.id : 0;
    			

  			  const data = {
  			    page: this.currentPage,
  			    categories: currentCategoryId
  			  };
			  //console.log('分页',this.activeIndex.id);
  			  this.quan_list_api(data, true); // 添加第二个参数表示是加载更多
  			},
			// 关闭播放音频
			clearAllAudio() {
    		  if(this.$refs.audioPlayer) {
    		    const audioCtx = this.$refs.audioPlayer.getAudioContext();
    		    audioCtx.stop();
    		    audioCtx.destroy();
    		  }
    		},
			quan(id){
				//console.log(id);
				try {
  				  uni.navigateTo({
  				    url: '/pages/quanzi/index?id='+id,
  				    fail: (err) => {
  				      console.error('跳转失败:', err)
  				    }
  				  })
  				} catch (e) {
  				  console.error('跳转异常:', e)
  				}
			},
			shenqing(){
				const uid = this.$store.state.memberuid;
				const keycode = this.$store.state.keycode;
				if (!uid || !keycode) {
				    uni.showToast({
				        title: '未登录',
				        icon: 'none'
				    });
					//this.denglu_xianshi = 1;
					var pc = this.$store.state.kuan.pc;
					if(pc){
						this.denglu_xianshi = 1; //pc
					} else {
						this.denglu_xianshi_weibu = 1; //移动
					}
				    return;
				}
				try {
  				  uni.navigateTo({
  				    url: '/pages/quan/shenqing',
  				    fail: (err) => {
  				      console.error('跳转失败:', err)
  				    }
  				  })
  				} catch (e) {
  				  console.error('跳转异常:', e)
  				}
			},
			// 申请的圈子统计
			async getShenqing_uid_list_api(){
				const uid = this.$store.state.memberuid;
                const keycode = this.$store.state.keycode;
				var get_data = getRequest(QuanApi.getShenqing_uid_list(uid,keycode));
				var res;	
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						// 转换时间戳为日期格式
						var list = res.data? res.data.data[0].list : {};
						var tongji = res.data.data && res.data.data[0].tongji;
						//
						this.shenquan_list = list;	
						this.shenquan_tongji = tongji;	
						}
					
				})
			},
			//加入圈子
			jiaquan(id){
				const uid = this.$store.state.memberuid;
			    const keycode = this.$store.state.keycode;
				if (!uid || !keycode) {
				    uni.showToast({
				        title: '未登录',
				        icon: 'none'
				    });
					var pc = this.$store.state.kuan.pc;
					if(pc){
						this.denglu_xianshi = 1; //pc
					} else {
						this.denglu_xianshi_weibu = 1; //移动
					}
					
				    return;
				}
				const data = {
					id: id
				}
				var post_data = postRequest(QuanApi.postJiaquan(uid,keycode),data);
				var res;
				post_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.data && res.data.data.code==1) {
						var e = this;
						this.quan_list_api(e,false);
						// 提示
						uni.showToast({
							icon: 'success', //有效的 icon 值为 success, loading, none
							title: '加入成功'
						});
					} else {
						// 提示
						uni.showToast({
							icon:'success', //有效的 icon 值为 success, loading, none
							title: '退出成功'

						});
					}
				})
			},
			denglu_close_get(){
				//console.log('关闭登录');
				this.denglu_xianshi_weibu = 0;
			},
			denglu_weibu(){
				this.denglu_xianshi_weibu = 1;
			},
			//站点设置
			wwwdataget(e){
				this.wwwData = e;
				//console.log('wwwdata',this.wwwdata);
			}
			
		}
	}
</script>

<style>

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		/*justify-content: center;*/
		/*background-color: #f3f3f3;*/
		
		margin-bottom: 0px;
		
		box-sizing: border-box;
		overflow-x: hidden;

	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	/* 屏幕宽度大于786px时隐藏uni-page-head */
    @media (min-width: 786px) {
        uni-page-head {
            display: none !important;
            opacity: 0 !important;
            height: 0 !important;
            visibility: hidden !important;
        }
    }
	/*.d-daohang{
		
		width: 600rpx;
	}*/
	/* 添加在style部分 */
	.d-daohang-zuo {
    position: fixed;
    left: 0;
    
    width: 180rpx;
    height: calc(100vh - 70rpx);
    background: #f5f5f5;
    z-index: 100;
	box-shadow: 2px 0 5px rgba(177, 177, 177, 0.1);
  }
  
  .d-daohang-you {
    position: fixed;
    left: 180rpx;
    
    width: 180rpx;
    height: calc(100vh - 70rpx);
    background: #fff;
    z-index: 100;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  }
  .d-erji-item {
    height: 60rpx;
    line-height: 60rpx;
    padding: 0 20rpx;
   /* border-bottom: 1px solid #f0f0f0;*/
  }
  
  .d-erji-item:active {
    background: #f5f5f5;
  }
  .you-guding-1 {
		position: fixed;
		top: 0; /* 根据头部高度调整 */
		/*box-shadow: -2px 0 5px rgba(0,0,0,0.1);*/
		transition: all 0.3s ease;
	}
    .you-guding-2 {
		position: fixed;

		top: 60px; /* 根据头部高度调整 */
		/*box-shadow: -2px 0 5px rgba(0,0,0,0.1);*/
		transition: all 0.3s ease;
	}


	
</style>
